package com.core.zyyz.amc.modules.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.zyyz.amc.modules.domain.AmcPubFunctionB;
import com.core.zyyz.amc.modules.service.AmcPubFunctionBService;
import com.core.common.core.page.TableDataInfo;

/**
 * 公用功能配置Controller
 *
 * @author lfs
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/amc/pubfunction")
public class AmcPubFunctionBController extends BaseController
{
    @Autowired
    private AmcPubFunctionBService amcPubFunctionBService;

    /**
     * 查询公用功能配置列表
     */
    @PreAuthorize("@ss.hasPermi('amc:pubfunction:list')")
    @GetMapping("/list")
    public TableDataInfo list(AmcPubFunctionB amcPubFunctionB)
    {
        startPage();
        List<AmcPubFunctionB> list = amcPubFunctionBService.selectAmcPubFunctionBList(amcPubFunctionB);
        return getDataTable(list);
    }


    /**
     * 获取公用功能配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('amc:pubfunction:query')")
    @GetMapping(value = "/{functionId}")
    public AjaxResult getInfo(@PathVariable("functionId") String functionId){
        return success(amcPubFunctionBService.selectAmcPubFunctionBByFunctionId(functionId));
    }

    /**
     * 新增公用功能配置
     */
    @PreAuthorize("@ss.hasPermi('amc:pubfunction:add')")
    @Log(title = "公用功能配置", businessType = BusinessType.INSERT)
    @PostMapping("/insertPubFunctionB")
    public AjaxResult add(@RequestBody AmcPubFunctionB amcPubFunctionB){
        return toAjax(amcPubFunctionBService.insertAmcPubFunctionB(amcPubFunctionB));
    }

    /**
     * 修改公用功能配置
     */
    @PreAuthorize("@ss.hasPermi('amc:pubfunction:edit')")
    @Log(title = "公用功能配置", businessType = BusinessType.UPDATE)
    @PostMapping("/updatePubFunctionB")
    public AjaxResult edit(@RequestBody AmcPubFunctionB amcPubFunctionB)
    {
        return toAjax(amcPubFunctionBService.updateAmcPubFunctionB(amcPubFunctionB));
    }

    /**
     * 删除公用功能配置
     */
    @PreAuthorize("@ss.hasPermi('amc:pubfunction:remove')")
    @Log(title = "公用功能配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{functionIds}")
    public AjaxResult remove(@PathVariable String[] functionIds)
    {
        return toAjax(amcPubFunctionBService.deleteAmcPubFunctionBByFunctionIds(functionIds));
    }
}
